package com.mapbased.wfw.bind;

import com.mapbased.wfw.*;
import javax.servlet.http.Cookie;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class CookieBinding
    extends AbstractBinding
{
    public CookieBinding(String exp)
    {
        super(exp);
    }

    /**
     * getDirectValue
     *
     * @param context RenderContext
     * @return Object
     * @todo Implement this com.mapbased.wfw.bind.AbstractBinding method
     */
    protected Object getDirectValue(RenderContext context)
    {
        Cookie[] c=context.getRequest().getCookies();
        if(c != null)
        {
            for(int i=0;i < c.length;i++)
            {
                if(this.attributeName.equals(c[i].getName()))
                {
                    return c[i];
                }
            }
        }
        return null;
    }
}
